﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using Adalbertus.BudgetPlanner.Domain;
using Caliburn.Micro;

namespace Adalbertus.BudgetPlanner.ViewModels.BudgetPlanning
{
    public class BudgetPlanDetailVM : PropertyChangedBase
    {
        private BudgetPlanDetail _wrappedBudgetPlanDetail;
        public BudgetPlanDetail WrappedBudgetPlanDetail
        {
            get
            {
                Contract.Ensures(Contract.Result<BudgetPlanDetail>() != null);
                return _wrappedBudgetPlanDetail;
            }
        }

        public BudgetPlanDetailVM(BudgetPlanDetail budgetPlanDetail)
        {
            Contract.Requires<ArgumentNullException>(budgetPlanDetail != null);
            _wrappedBudgetPlanDetail = budgetPlanDetail;
        }

        public decimal Value
        {
            get
            {
                Contract.Ensures(Contract.Result<decimal>() > 0);
                return WrappedBudgetPlanDetail.Value;
            }
            set
            {
                Contract.Requires<ArgumentException>(value > 0);
                WrappedBudgetPlanDetail.Value = value;
                NotifyOfPropertyChange(() => Value);
            }
        }

        public string Description
        {
            get { return WrappedBudgetPlanDetail.Description; }
            set
            {
                WrappedBudgetPlanDetail.Description = value;
                NotifyOfPropertyChange(() => Description);
            }
        }
    }
}
